fEmail_Outlook_CreateMail SentFrom

Help. Want to auto-send an email "from" this other account.

Below is my function to make and send an Outlook email. I want it to send the email from the DOORS admin account, not the current user (me). When I "Display" the email with this function (parameter in_AutoSend = false) and then manually send it, it works; the email is "from" the other address. But when I "Send" the email with this funtion (parameter in_AutoSend = true), it seems to ignore the "SentFrom" field and sends it always from "me".

I see my specified "SendFrom" field must be a valid address (which is isn't in this example).
 

string    gl_Ole_AppOutlook     = "Outlook.Application"       // Windows recognizes this as a running Outlook
 
bool    fOle_OK(string in_ResultFromOleCommand, in_NameOfOleCommand)
{
        if (!null in_ResultFromOleCommand)
        {  print "XX OLE Error:\t" in_NameOfOleCommand "\t[" in_ResultFromOleCommand "]\n"
         return(false)
        }
        else return(true)
}
 
 
//******************************
bool    fEmail_Outlook_CreateMail(bool in_AutoSend, string in_SendTo, in_SendCC,
                 in_SendBCC, in_SentFrom, in_Subject, in_Body)
{     // Create the Email message which requires that Outlook.exe is running.
        // in_SendTo, in_SendCC, in_SendBCC, and in_SentFrom should be valid 
        //      Email addresses separated by semi-colons;.
        // Send the Message when in_AutoSend, otherwise just display it.
        // When in_SentFrom is null then no such field is used
 
 
        bool    Result  = false
        OleAutoObj      oaoMessage      = null
        OleAutoObj      oaoOutlook      = oleGetAutoObject(gl_Ole_AppOutlook)
        if (null oaoOutlook)
        {  fOle_OK("Outlook not running", "GetOutlook")   // Log Error
           return(false)
        }
        OleAutoArgs     autoArgs        = create()
        clear(autoArgs)
        put(autoArgs, 0)           // 0 is Outlook's symbolic constant for mail item
 
        if(     fOle_OK(oleMethod(oaoOutlook, "CreateItem", autoArgs, oaoMessage), "CreateItem")    and
                fOle_OK(olePut(oaoMessage, "To",      in_SendTo),  "To")    and
                fOle_OK(olePut(oaoMessage, "CC",      in_SendCC),  "CC")    and
                fOle_OK(olePut(oaoMessage, "BCC",     in_SendBCC), "BCC")   and
                fOle_OK(olePut(oaoMessage, "Subject", in_Subject), "Subj")  and
                fOle_OK(olePut(oaoMessage, "Body",    in_Body),    "Body")  and
                (null in_SentFrom       or
                 fOle_OK(olePut(oaoMessage, "SentOnBehalfOfName", in_SentFrom),  "SentFrom")
                )
          )
        {             // Message created OK. Send or just Show it
           if (in_AutoSend)
                Result = fOle_OK(oleMethod(oaoMessage, "Send"), "Send")
           else Result = fOle_OK(oleMethod(oaoMessage, "Display"), "Display")
        }
        else Result = false
        delete(autoArgs)
        return(Result)
}    // end fEmail_Outlook_CreateMail()
 
 
string  ToField = "Louie.Landale@ngc.com"
string  SentFrom = "MyDoorsAdmin@ngcXX.com"
 
bool    SendIt = confirm("Confirm to Send; Cancel to Display")
fEmail_Outlook_CreateMail(SendIt, ToField, "", "", SentFrom , "Subject", "Body")

 

 

  • Louie

 

 


llandale - Tue Feb 08 10:42:57 EST 2011

Re: fEmail_Outlook_CreateMail SentFrom
Mathias Mamsch - Tue Feb 08 12:12:48 EST 2011

On my computer your code works fine. In both cases it is sent with the right "on behalf of" address. When I click "Confirm" I get an Outlook message "A script is trying to send an email, do you want to allow that?". And when I confirm this, the email is sent out correctly. Maybe something with your Outlook/MAPI configuration? I am using Outlook 2003, SP2. Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: fEmail_Outlook_CreateMail SentFrom
llandale - Wed Feb 09 09:26:17 EST 2011

Mathias Mamsch - Tue Feb 08 12:12:48 EST 2011
On my computer your code works fine. In both cases it is sent with the right "on behalf of" address. When I click "Confirm" I get an Outlook message "A script is trying to send an email, do you want to allow that?". And when I confirm this, the email is sent out correctly. Maybe something with your Outlook/MAPI configuration? I am using Outlook 2003, SP2. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Guess I'm brain dead. Got a rule that copies my "sent" messages to my inbox. So I run the code and look at my Inbox, and I see a message from me to me. But that's my 'sent' message. If I wait 30 seconds I actually GET the message I sent, and THAT messages says I sent it on behalf of. Guess that's good enough.

So in practice the calling function will add the From field also to the BCC field, so the DOORS admin account actually gets the message I sent and has some record of it.

Thanks.

  • Louie

Re: fEmail_Outlook_CreateMail SentFrom
Stig0498 - Tue Feb 22 09:32:52 EST 2011

llandale - Wed Feb 09 09:26:17 EST 2011
Guess I'm brain dead. Got a rule that copies my "sent" messages to my inbox. So I run the code and look at my Inbox, and I see a message from me to me. But that's my 'sent' message. If I wait 30 seconds I actually GET the message I sent, and THAT messages says I sent it on behalf of. Guess that's good enough.

So in practice the calling function will add the From field also to the BCC field, so the DOORS admin account actually gets the message I sent and has some record of it.

Thanks.

  • Louie

Hi,
I just tried the code above but get the following OLE error:

CreateItem

Re: fEmail_Outlook_CreateMail SentFrom
Stig0498 - Tue Feb 22 09:35:48 EST 2011

llandale - Wed Feb 09 09:26:17 EST 2011
Guess I'm brain dead. Got a rule that copies my "sent" messages to my inbox. So I run the code and look at my Inbox, and I see a message from me to me. But that's my 'sent' message. If I wait 30 seconds I actually GET the message I sent, and THAT messages says I sent it on behalf of. Guess that's good enough.

So in practice the calling function will add the From field also to the BCC field, so the DOORS admin account actually gets the message I sent and has some record of it.

Thanks.

  • Louie

Hi,
I just tried the code above but get the following OLE error:

CreateItem OLE failure: Parameter not optional.

any thoughts?

Thanks

Re: fEmail_Outlook_CreateMail SentFrom
Mathias Mamsch - Tue Feb 22 10:51:43 EST 2011

Stig0498 - Tue Feb 22 09:35:48 EST 2011
Hi,
I just tried the code above but get the following OLE error:

CreateItem OLE failure: Parameter not optional.

any thoughts?

Thanks

What version of Outlook are you using? Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: fEmail_Outlook_CreateMail SentFrom
Stig0498 - Wed Feb 23 10:10:53 EST 2011

Mathias Mamsch - Tue Feb 22 10:51:43 EST 2011
What version of Outlook are you using? Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Hi
I am using Outlook 2003

just realised i have missed out the following lines of code

clear(autoArgs)
put(autoArgs, 0)

This stops the error but DOORS just now hangs when I run it

Re: fEmail_Outlook_CreateMail SentFrom
Stig0498 - Wed Feb 23 10:27:25 EST 2011

Stig0498 - Wed Feb 23 10:10:53 EST 2011
Hi
I am using Outlook 2003

just realised i have missed out the following lines of code

clear(autoArgs)
put(autoArgs, 0)

This stops the error but DOORS just now hangs when I run it

Scratch that, working fine now. Thanks

Re: fEmail_Outlook_CreateMail SentFrom
SystemAdmin - Wed Feb 15 08:49:31 EST 2012

This is an amazing function.
Is there a possibility to send an email to multiple groups?
I'm used to do it with the sendEmailNotification function, using the Skip list

Re: fEmail_Outlook_CreateMail SentFrom
llandale - Wed Feb 15 11:43:24 EST 2012

SystemAdmin - Wed Feb 15 08:49:31 EST 2012
This is an amazing function.
Is there a possibility to send an email to multiple groups?
I'm used to do it with the sendEmailNotification function, using the Skip list

Maybe this works:

string MakeDelimitedList(Skip in_skp, string in_Delim)
{   // Turn the Skip into a delimited list
    // Skip's "Key" must be type "string"
   if (null in_skp)   return("")
   Buffer buf = create
   string Data, Key
   string Delim = ""
   for Data in in_skp do
   {  Key = (string key in_skp)
      buf += Delim
      buf += Key
      Delim = in_Delim    // get ready for next entry
   }
   string Results = stringOf(buf)
   delete(buf)
   return(Results)
}  // end MakeDelimitedList()
// I suppose you would do this:
string ToField = MakeDelimitedList(skpMyEmailGroups, "; ")


-Louie

Re: fEmail_Outlook_CreateMail SentFrom
SystemAdmin - Thu Apr 04 05:31:32 EDT 2013

llandale - Wed Feb 15 11:43:24 EST 2012

Maybe this works:

string MakeDelimitedList(Skip in_skp, string in_Delim)
{   // Turn the Skip into a delimited list
    // Skip's "Key" must be type "string"
   if (null in_skp)   return("")
   Buffer buf = create
   string Data, Key
   string Delim = ""
   for Data in in_skp do
   {  Key = (string key in_skp)
      buf += Delim
      buf += Key
      Delim = in_Delim    // get ready for next entry
   }
   string Results = stringOf(buf)
   delete(buf)
   return(Results)
}  // end MakeDelimitedList()
// I suppose you would do this:
string ToField = MakeDelimitedList(skpMyEmailGroups, "; ")


-Louie

Hi,

Can you please let me know how to add the recipient email address in Cc Field in the script.

Moreover it would be great if the particular mail has to be sent automatically in particular time.is that possible?

Thanks,
Shri

Re: fEmail_Outlook_CreateMail SentFrom
BuddyD - Mon Apr 15 16:42:35 EDT 2013

SystemAdmin - Thu Apr 04 05:31:32 EDT 2013
Hi,

Can you please let me know how to add the recipient email address in Cc Field in the script.

Moreover it would be great if the particular mail has to be sent automatically in particular time.is that possible?

Thanks,
Shri

I'm going to try this also, I want to thank you a head of time.

Johnny

Re: fEmail_Outlook_CreateMail SentFrom
BuddyD - Tue Apr 16 12:47:25 EDT 2013

BuddyD - Mon Apr 15 16:42:35 EDT 2013

I'm going to try this also, I want to thank you a head of time.

Johnny

Still in clean up of code mode, I'm using Outlook 2007.  I think I'm missing some code that is not included above.  sbhupa do you have your code working.  Is thier a missing piece.


Attachments

IBMDXLSend.dxl